//用户管理-用户列表
App.util.ns('Client.Staff');
App.pages.add((function(){
    var NS = Client.Staff;
    var page = new App.Page({
        name: 'client/staff/index'
    });
    //页面初始化
    page.initStack.add('dataTable', function(){
        //面包屑导航
        this.setBreadcrumb([{
            icon: '<i class="fa fa-user"></i>',
            content: '员工管理'
        }, {
            content: '员工列表'
        }]);
        this.dataTable = new App.DataTable({
            baseUrl: '/client/staff',
            dataUrl: 'lists',
            table: {
                id: 'id',
                main: 0,
                columns: App.util.copy(NS.Conf.columns)
            },
            filter: [
                {type: 'keywords'},
                {type: 'select', name: 'client_bind_status', title: '绑定状态', width: '120px', items: [
                    [1, '待审核'],
                    [2, '绑定完成'],
                    [3, '绑定未完成']
                ]},
                {type: 'timeRange'}
            ],
            menu: [
                {parent: 'add', permission: 'op:client.staff.staff.create'},
                {parent: 'view', permission: 'op:client.staff.staff.detail'},
                {parent: 'edit', permission: 'op:client.staff.staff.update'},
                {type: 'inline', permission: 'op:client.staff.staff.passApply', name: '通过', 
                    operation: {type: 'change', url: 'passApply'}, 
                    conditions: [['client_bind_status', '1']]
                },
                {type: 'inline', permission: 'op:client.staff.staff.rejectApply', name: '驳回', 
                    operation: {type: 'change', url: 'rejectApply'}, 
                    conditions: [['client_bind_status', '1']]
                },
                {type: 'inline', permission: 'op:client.staff.staff.close', name: '解除绑定', 
                    operation: {type: 'change', url: 'close'}, 
                    conditions: [['client_bind_status', '2']]
                },
//                {parent: 'drop', permission: 'op:client.staff.staff.delete'},
                {type: 'multi', name: '绑定状态', openable: true, 
                    items: [
                        {type: 'multi', permission: 'op:client.staff.staff.multiPassApply', name: '审核通过', 
                            operation: {type: 'change', url: 'multiPassApply', confirm: true}
                        },
                        {type: 'multi', permission: 'op:client.staff.staff.multiRejectApply', name: '审核驳回', 
                            operation: {type: 'change', url: 'multiRejectApply', confirm: true}
                        },
                        {type: 'multi', permission: 'op:client.staff.staff.multiClose', name: '解除绑定', 
                            operation: {type: 'change', url: 'multiClose', confirm: true}
                        }
                    ], 
                    permission:[
                        'op:client.staff.staff.multiPassApply',
                        'op:client.staff.staff.multiRejectApply',
                        'op:client.staff.staff.multiOpen',
                        'op:client.staff.staff.multiClose'
                    ]
                },
//                {parent: 'multiDrop', permission: 'op:client.staff.staff.multiDelete'},
                {parent: 'oplog', permission: 'op:client.staff.staff.getOpLogs'}
            ],
            detail: {
                form: {
                    items: App.util.copy(NS.Conf.form)
                }
            }
        }, page);
        this.dataTable.fix(this.contentContainer);
        this.dataTable.loadData();
    });
    //页面刷新
    page.refreshStack.add('dataTable', function(){
        this.dataTable.loadData(true);
    });
    //页面销毁
    page.destroyStack.add('dataTable', function(){
        this.dataTable.destroy();
    });
    return page;
})());